﻿@model List<_8_21_Classwork_Cafe.Models.CafeShop>
@{
    ViewBag.Title = "Home Page";
}
<div class="jumbotron"><h1>Welcome To Cafe Review Central </h1></div>
<table class="table table-hover table-condensed">
    <tr>
        <th colspan="4" class="text-center">
            <h2>List of Cafes</h2>
            <div class="pull-left">
                Sort By:
                
                    <select name="sort" id="sort">
                        <option value="1">Highest Rated</option>
                        <option value="2">Least Rated</option>
                        <option value="3">Most Reviews</option>
                        <option value="4">Least Reviews</option>
                        <option value="5">Top 5 Cafe's</option>
                    </select>
                    <input type="submit" class="btn btn-primary btn-sm" onclick="location.href='/Home/SortList/'+ document.getElementById('sort').value" value="Apply Filters" />
                
            </div>
            <div>
                <button class="pull-right btn btn-success" onclick="location.href='/Home/AddCafe'">Add Cafe</button>
            </div>
        </th>
    </tr>
    <tr>
        <th></th>
        <th>Cafe Name</th>
        <th>Cafe Info</th>
        <th>Average Rating</th>
    </tr>
    @for (int i = 0; i < @Model.Count;i++ ){
        <tr onclick="location.href='/Home/Details/@Model[i].ID'">
            <td style="height:50px;width:50px;"><img class="img-responsive" src="@Model[i].Image" /></td>
            <td>@Model[i].Name</td>
            <td>@Model[i].Info</td>
            <td>
                @if (@Model[i].AvgRating() == 1){
                    <div>&#9733&#9734&#9734&#9734&#9734</div><br />
                }
                else if (@Model[i].AvgRating() == 2){
                    <div>&#9733&#9733&#9734&#9734&#9734</div><br />
                }else if (@Model[i].AvgRating() == 3){
                    <div>&#9733&#9733&#9733&#9734&#9734</div><br />
                }
                else if (@Model[i].AvgRating() == 4)
                {
                    <div>&#9733&#9733&#9733&#9733&#9734</div><br />
                }
                else if (@Model[i].AvgRating() == 5)
                {
                    <div>&#9733&#9733&#9733&#9733&#9733</div><br />
                }
                else if (@Model[i].AvgRating() == 0)
                {
                    <div>&#9734&#9734&#9734&#9734&#9734</div><br />
                }
            </td>
        </tr>
        if (i == 4) { break; }
    }
    
</table>